"""
主页类
"""
from selenium.webdriver.common.by import By
from framwork.pages.base_page import BasePage


class HomePage(BasePage):
    url = "/crm/index.php?m=dynamic&a=index"
    tips_success_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')
    product_locator = (By.LINK_TEXT, '产品')
    tx_locator = (By.CSS_SELECTOR,
                  "body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul.nav.pull-right > li:nth-child(6) > a")
    grzl_locator = (By.LINK_TEXT, "个人资料")
    wdmb_locator = (By.LINK_TEXT, "我的面板")
    operation_log_locator = (By.LINK_TEXT, "操作日志")
    sj_locator = (By.LINK_TEXT, "商机")
    ht_locator = (By.LINK_TEXT, "合同")
    zzjg_locator = (By.LINK_TEXT, "组织架构")

    def tips_success_text(self):
        '''主页登录成功文本'''
        text = self.driver.find_element(*self.tips_success_locator).text
        return text

    def click_product(self):
        '''主页点击产品'''
        self.find_element(self.product_locator).click()

    def click_tx(self):
        '''主页点击头像'''
        self.find_element(self.tx_locator).click()

    def click_grzl(self):
        '''主页点击个人资料'''
        self.find_element(self.grzl_locator).click()

    def click_wdmb(self):
        '''主页点击我的面板'''
        self.find_element(self.wdmb_locator).click()

    def click_operation_log(self):
        '''主页点击操作日志'''
        self.find_element(self.operation_log_locator).click()

    def click_opportunity(self):
        """主页点击商机"""
        self.find_element(self.sj_locator).click()

    def click_ht(self):
        '''主页点击合同'''
        self.find_element(self.ht_locator).click()

    def click_zzjg(self):
        '''主页点击组织架构'''
        self.find_element(self.zzjg_locator).click()

